package com.fishery.processing.dao;

import com.fishery.processing.entity.Qualification;
import com.fishery.processing.mapper.QualificationMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author run
 * @since 2021/1/14 16:42
 */
@Component
public class QualificationDao {

    @Autowired
    private QualificationMapper qualificationMapper;

    public int addQualification(Qualification qualification){
        return qualificationMapper.insert(qualification);
    }

    public int updateQualification(Qualification qualification){
        return qualificationMapper.updateById(qualification);
    }

    public int removeQualification(String qualificationId){
        return qualificationMapper.deleteById(qualificationId);
    }

    public Qualification findQualificationById(String qualificationId){
        return qualificationMapper.selectById(qualificationId);
    }

    public List<Qualification> findQualificationOfProduct(String productId){
        Map<String,Object> map = new HashMap<>(1,1);
        map.put("product_id",productId);
        return qualificationMapper.selectByMap(map);
    }
}
